package cn.funnyxb.powerremember.uis.task.done.autobrow;

import cn.funnyxb.powerremember.beans.AWord;
import cn.funnyxb.powerremember.db.tables.Tbholder_taskWithWords;
import cn.funnyxb.tools.appFrame.debugTool.Debuger;

public class ContentController
{
  private static ContentController controler = null;
  private volatile int countOfThisUnit;
  private volatile int currentId;
  private volatile int currentIndexOfThisUnit;
  private int rangeEndId;
  private int rangeStartId;
  private boolean reverseBrowWhenAutoMode = false;
  private String sqlFilter;
  private Tbholder_taskWithWords tbholder;

  public ContentController(int paramInt1, int paramInt2, Tbholder_taskWithWords paramTbholder_taskWithWords, String paramString)
  {
    log("rangestart=" + paramInt1 + ",rangeend=" + paramInt2);
    this.rangeStartId = paramInt1;
    this.rangeEndId = paramInt2;
    controler = this;
    this.tbholder = paramTbholder_taskWithWords;
    this.sqlFilter = paramString;
    reset2Head();
    computeCnt();
  }

  private void computeCnt()
  {
    this.countOfThisUnit = this.tbholder.queryAPartCnt(this.rangeStartId, this.rangeEndId, this.sqlFilter);
  }

  public static ContentController getControler()
  {
    return controler;
  }

  private void log(String paramString)
  {
    Debuger.log("contentctrl", paramString);
  }

  public void changeAutoBrowDirection(boolean paramBoolean)
  {
    this.reverseBrowWhenAutoMode = paramBoolean;
  }

  public int getCountOfThisUnit()
  {
    return this.countOfThisUnit;
  }

  public int getCurrentId()
  {
    return this.currentId;
  }

  public int getCurrentIndexOfThisUnit()
  {
    return this.currentIndexOfThisUnit;
  }

  public AWord getCurrentWord()
  {
    return this.tbholder.queryAWordById(this.currentId);
  }

  public AWord getNextWhenAutoMode()
  {
    if (this.reverseBrowWhenAutoMode);
    for (AWord localAWord = getPreWord(); ; localAWord = getNextWord())
      return localAWord;
  }

  public AWord getNextWithDirect()
  {
    if (this.reverseBrowWhenAutoMode);
    for (AWord localAWord = getPreWord(); ; localAWord = getNextWord())
      return localAWord;
  }

  public AWord getNextWord()
  {
    monitorenter;
    Object localObject2;
    AWord localAWord;
    try
    {
      boolean bool = hasNext();
      if (!(bool));
      for (localObject2 = null; ; localObject2 = null)
      {
        return localObject2;
        log("before getNext,currentid=" + this.currentId + "rangeStartid=" + this.rangeStartId + ",rangeEndid=" + this.rangeEndId);
        localAWord = this.tbholder.queryAWord(false, this.rangeStartId, this.rangeEndId, 1 + this.currentId, this.sqlFilter);
        log("getNext" + localAWord);
        if (localAWord != null)
          break;
      }
      this.currentId = localAWord.getId();
      this.currentIndexOfThisUnit = (1 + this.currentIndexOfThisUnit);
    }
    finally
    {
      monitorexit;
    }
  }

  public AWord getPreWord()
  {
    monitorenter;
    Object localObject2;
    AWord localAWord;
    try
    {
      boolean bool = hasPre();
      if (!(bool));
      for (localObject2 = null; ; localObject2 = null)
      {
        return localObject2;
        localAWord = this.tbholder.queryAWord(true, this.rangeStartId, this.rangeEndId, this.currentId - 1, this.sqlFilter);
        log("getpre,word=" + localAWord + ",currentId=" + this.currentId);
        if (localAWord != null)
          break;
      }
      this.currentId = localAWord.getId();
      this.currentIndexOfThisUnit -= 1;
    }
    finally
    {
      monitorexit;
    }
  }

  public int getRangeEndId()
  {
    return this.rangeEndId;
  }

  public int getRangeStartId()
  {
    return this.rangeStartId;
  }

  public String getSqlFilter()
  {
    return this.sqlFilter;
  }

  public boolean hasMoreWithDirect()
  {
    if (this.reverseBrowWhenAutoMode);
    for (boolean bool = hasPre(); ; bool = hasNext())
      return bool;
  }

  public boolean hasNext()
  {
    monitorenter;
    try
    {
      int i = this.currentIndexOfThisUnit;
      int j = this.countOfThisUnit;
      if (i < j)
      {
        k = 1;
        return k;
      }
      int k = 0;
    }
    finally
    {
      monitorexit;
    }
  }

  public boolean hasPre()
  {
    monitorenter;
    try
    {
      int i = this.currentIndexOfThisUnit;
      if (i > 1)
      {
        j = 1;
        return j;
      }
      int j = 0;
    }
    finally
    {
      monitorexit;
    }
  }

  public boolean isInRange()
  {
    if ((this.currentIndexOfThisUnit > 0) && (this.currentIndexOfThisUnit <= this.countOfThisUnit));
    for (int i = 1; ; i = 0)
      return i;
  }

  public void reset2Head()
  {
    this.currentId = -1;
    this.currentIndexOfThisUnit = 0;
  }

  public void reset2Tail()
  {
    this.currentId = (1 + this.rangeEndId);
    this.currentIndexOfThisUnit = (1 + this.countOfThisUnit);
  }

  public void resetWithDirect()
  {
    if (this.reverseBrowWhenAutoMode)
      reset2Tail();
    while (true)
    {
      return;
      reset2Head();
    }
  }

  public void setSqlFilter(String paramString)
  {
    this.sqlFilter = paramString;
    computeCnt();
  }
}

/* Location:           E:\Desktop\复件 classes_dex2jar.jar
 * Qualified Name:     cn.funnyxb.powerremember.uis.task.done.autobrow.ContentController
 * JD-Core Version:    0.5.3
 */